home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
pcr
/
pcr4_4.lha
/
DIST
/
gc
/
GCblack_list.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-16
|
3KB
|
98 lines
/* begincopyright
Copyright (c) 1991-1992 Xerox Corporation. All rights reserved.
Use and copying of this software and preparation of derivative works based
upon this software are permitted. Any distribution of this software or
derivative works must comply with all applicable United States export
control laws. This software is made available AS IS, and Xerox Corporation
makes no warranty about the software, its performance or its conformity to
any specification. Any person obtaining a copy of this software is requested
to send their name and post office or electronic mail address to:
PCR Coordinator
Xerox PARC
3333 Coyote Hill Rd.
Palo Alto, CA 94304
endcopyright */
# include <xr/GCPrivate.h>
# ifdef BLACK_LIST
/*
* Black list entries contain 2 bits each:
* 0 ==> not black listed
* 1 ==> recently black listed
* 2 ==> about to be removed from black list
*/
/* Schedule all pages to be removed from black list. The next routine */
/* actually removes those that were not added again in the interim. */
void GC_prepare_to_clear_black_list()
{
register long i;
register long lim =
(struct hblk *) GC_heaplim - (struct hblk *) GC_heapstart;
for (i = 0; i < lim; i++) {
GC_blacklist[i] <<= 1;
}
}
void GC_clear_black_list()
{
register long i;
register long lim =
(struct hblk *) GC_heaplim - (struct hblk *) GC_heapstart;
for (i = 0; i < lim; i++) {
GC_blacklist[i] &= 1;
}
}
/* P is not a valid pointer reference, but it passed quicktest. */
/* If it is likely to result in a later false reference, than */
/* add the block it points to the black list. */
void GC_add_to_black_list(p)
unsigned long p;
{
register char * GC_heapstart_reg = GC_heapstart;
register int old_black_list_val;
register struct hblk * h;
# define GC_heapstart GC_heapstart_reg
if (p >= (unsigned long) ((struct hblk *) GC_heapstart + MAP_SIZE)) {
return;
}
if ((char *)p < GC_heapstart) {
GC_abort("GC_add_to_black_list: bad pointer\n");
}
h = HBLKPTR(p);
old_black_list_val = black_list(h);
if (old_black_list_val != 0) {
if (old_black_list_val == 2) {
/* May be interior pointer, but page was previously bad. */
black_list(h) = 1;
}
return;
}
if (get_map(h) != HBLK_INVALID) {
/* May be a pointer to the interior of a previously allocated */
/* object. That's not enough to black list it, unless it was */
/* previously already black listed. */
return;
}
# ifdef PRINTSTATS
GC_vprintf("Black listing 0x%X (saw 0x%X)\n", h, p);
# endif
black_list(h) = 1;
# undef GC_heapstart
}
void GC_rm_from_blacklist(hbp)
struct hblk * hbp;
{
black_list(hbp) = 0;
}
# endif /* BLACK_LIST */